<template>
  <div>
    <h1>Welcome</h1>
    <button @click="send">发送请求</button>
    <button @click="abort">发送中断请求</button>
  </div>
</template>

<script>
import { getLoginLog } from "@/api"
  export default{
    methods:{
      send(){
        getLoginLog(this)
        .then(res => {
          console.log(res);
        })
      },
      abort(){
        // console.log(this.cancel);   //默认在点击请求之后，在点这个，就会打印出函数，所有有如下的if判断
          if( typeof this.cancel === "function" ){
              this.cancel()
          }
      }
    }
  }
</script>